//package com.example.myapplication
//
//import androidx.test.ext.junit.rules.ActivityScenarioRule
//import androidx.test.ext.junit.runners.AndroidJUnit4
//import androidx.test.filters.LargeTest
//import com.example.myapplication.clean_craftsmanship.*
//import org.junit.Assert.*
//import org.junit.Rule
//import org.junit.Test
//import org.junit.runner.RunWith
//
///**
// *Create by Fanketly on 2022/9/3
// *Gitee:https://gitee.com/fanketly
// *desc:第三章测试替身
// */
//
//@RunWith(AndroidJUnit4::class)
//@LargeTest
//class LoginTest {
//    @get:Rule
//    var rule = ActivityScenarioRule(LoginActivity::class.java)
//
//    @Test
//    fun whenClosed() {
//        val authenticator = AuthenticatorDummy()
//        val loginDialog = LoginDialog(authenticator)
//        loginDialog.sendEvent(LoginEvent.CLOSE)
////        onView(withId(R.id.button)).perform(click())
////            .check(matches(isDisplayed()))
//    }
//
//    @Test
//    fun whenReject() {
//        val authenticator = RejectingAuthenticator()
//        val loginDialog = LoginDialog(authenticator)
//        assertFalse(loginDialog.submit("", ""))
//    }
//
//    @Test
//    fun whenPromiscuous() {
//        val authenticator = PromiscuousAuthenticator()
//        val loginDialog = LoginDialog(authenticator)
//        assertTrue(loginDialog.submit("", ""))
//    }
//
//    @Test
//    fun correctlyInvokes() {
//        val authenticator = SpyAuthenticator()
//        val loginDialog = LoginDialog(authenticator)
//        authenticator.result = true
//        assertTrue(loginDialog.submit("user", "pw"))
//        assertEquals("user", authenticator.lastUsername)
//        assertEquals("pw", authenticator.lastPassword)
//        assertEquals(1, authenticator.count)
//
//    }
//
//    @Test
//    fun validated() {
//        val authenticator = MockAuthenticator("user", "pw", 1)
//        val loginDialog = LoginDialog(authenticator)
//        authenticator.result = true
//        assertTrue(loginDialog.submit("user", "pw"))
//        assertTrue(authenticator.validate())
//    }
//
//    @Test
//    fun badPasswordAttempt() {
//        val authenticator = FakeAuthenticator()
//        val loginDialog = LoginDialog(authenticator)
//        assertFalse(loginDialog.submit("user", "bad"))
//    }
//
//    @Test
//    fun goodPasswordAttempt() {
//        val authenticator = FakeAuthenticator()
//        val loginDialog = LoginDialog(authenticator)
//        assertFalse(loginDialog.submit("user", "good"))
//    }
//}